package com.design.proxy.calc;

// 计算器远程代理
class CalculatorProxy implements Calculator {
    private RemoteCalculator remoteCalculator;

    public CalculatorProxy() {
        // 在实际应用中，可能需要进行远程服务器的连接和认证
        // 这里简化为直接创建远程计算器对象
        remoteCalculator = new RemoteCalculator();
    }

    @Override
    public int add(int a, int b) {
        System.out.println("Proxy: Performing addition...");
        return remoteCalculator.add(a, b);
    }

    @Override
    public int subtract(int a, int b) {
        System.out.println("Proxy: Performing subtraction...");
        return remoteCalculator.subtract(a, b);
    }

    @Override
    public int multiply(int a, int b) {
        System.out.println("Proxy: Performing multiplication...");
        return remoteCalculator.multiply(a, b);
    }

    @Override
    public int divide(int a, int b) {
        System.out.println("Proxy: Performing division...");
        return remoteCalculator.divide(a, b);
    }
}
